package com.xiyu.service.controller.admin.elder;
import com.xiyu.service.vo.elder.checkOut.CheckOutGetOutput;
import com.xiyu.service.vo.elder.checkOut.CheckOutUpdateStatusInput;
import com.xiyu.service.vo.elder.checkOut.CheckOutUpdateInput;
import com.xiyu.service.vo.elder.checkOut.CheckOutCreateInput;
import com.xiyu.service.vo.elder.checkOut.CheckOutPageQueryOutput;
import com.xiyu.service.vo.elder.checkOut.CheckOutPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.elder.CheckOutService;

@Tag(name = "退住登记")
@RestController
@RequestMapping("/elder/check-out")
@Validated
public class CheckOutController {

    @Resource
    private CheckOutService checkOutService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询退住登记")
    @PreAuthorize("@ss.hasPermission('elder:checkOut:query')")
    public CommonResult<PageResult<CheckOutPageQueryOutput>> pageQuery(@Valid CheckOutPageQueryInput inputVO) {
        return success(checkOutService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新建退住登记")
    @PreAuthorize("@ss.hasPermission('elder:checkOut:create')")
    public CommonResult<Long> create(@Valid @RequestBody CheckOutCreateInput inputVO) {
        return success(checkOutService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新退住登记")
    @PreAuthorize("@ss.hasPermission('elder:checkOut:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody CheckOutUpdateInput inputVO) {
        return success(checkOutService.update(inputVO));
    }

    @PutMapping("/update-status")
    @Operation(summary = "更新退住登记状态")
    public CommonResult<Boolean> updateStatus(@Valid @RequestBody CheckOutUpdateStatusInput inputVO) {
        return success(checkOutService.updateStatus(inputVO));
    }

    @GetMapping("/get")
    @Operation(summary = "获取单个退住登记")
    @Parameter(name = "id", description = "退住登记主键ID", example = "")
    public CommonResult<CheckOutGetOutput> get(@RequestParam("id") Long id) {
        return success(checkOutService.get(id));
    }

}
